package com.kawins.supers.message.socket.listener;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;

import java.util.UUID;

/**
 * @author rankai
 *         createTime 2018-01-2018/1/22 18:40
 */
public abstract class SocketMessageListener implements MessageListener {

    protected static final String SOCKET_SERVER_UUID = UUID.randomUUID().toString();

    @Override
    public void onMessage(Message message, byte[] bytes) {
        onMessage(new MessageBean(message.getChannel(), message.getBody()));
    }

    /**
     * 接到订阅消息执行的方法
     *
     * @param message
     */
    protected abstract void onMessage(MessageBean message);
}
